//
//  LoginTextFieldView.m
//  GaoXunTravel
//
//  Created by 训网高 on 2017/11/13.
//  Copyright © 2017年 May. All rights reserved.
//

#import "LoginTextFieldView.h"

@implementation LoginTextFieldView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame withTarget:(id)target withPlaceholderString:(NSString *)placeholder withLeftImageNamed:(NSString *)leftName withRightImage:(NSString *)rightName {
    self = [super initWithFrame:frame];
    if (self) {
        [self setSubViewsWithPlaceholer:placeholder withLeftImage:leftName withRightImage:rightName];
        _textField.delegate = target;
    }
    return self;
}

- (void)setSubViewsWithPlaceholer:(NSString *)placeholderString withLeftImage:(NSString *)leftName withRightImage:(NSString *)rightName {
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH-40, 0.5)];
    lineView.backgroundColor = [UIColor whiteColor];
    [self addSubview:lineView];
    
    UIImageView *leftImage = [[UIImageView alloc] initWithFrame:CGRectMake(20, 10, 20, 20)];
    leftImage.image = [UIImage imageNamed:leftName];
    [self addSubview:leftImage];
    
    _rightImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width-40, 10, 20, 20)];
    _rightImage.image = [UIImage imageNamed:rightName];
    
    if ([rightName isEqualToString:@""]) {
        _rightImage.hidden = YES;
    }
    
    [self addSubview:_rightImage];
    
//    //验证码
//    _codeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    _codeBtn.frame = CGRectMake(self.frame.size.width-120-20, 0, 120, 40);
//    [_codeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
//    [_codeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    _codeBtn.backgroundColor = [UIColor clearColor];
//    _codeBtn.layer.borderWidth = 0.5;
//    _codeBtn.layer.borderColor = [UIColor whiteColor].CGColor;
//    _codeBtn.layer.cornerRadius = 20;
//    _codeBtn.layer.masksToBounds = YES;
//    if (isHide) {
//        _codeBtn.hidden = YES;
//    }
//    [self addSubview:_codeBtn];
    
//    //图形验证码
//    _graphicBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    _graphicBtn.frame = CGRectMake(self.frame.size.width-120-20, 0, 120, 40);
//    [_graphicBtn setBackgroundImage:[UIImage imageNamed:graphicImageName] forState:UIControlStateNormal];
//    if (<#condition#>) {
//        <#statements#>
//    }
    
    
    _textField = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(leftImage.frame)+10, 10, self.frame.size.width-100, 20)];
    //设置placeholder字体的颜色
    [_textField setAttributedPlaceholder:[[NSAttributedString alloc] initWithString:placeholderString attributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}]];
    [_textField setFont:[UIFont systemFontOfSize:14]];
    _textField.textColor = [UIColor whiteColor];
    _textField.placeholder = placeholderString;
    _textField.borderStyle = UITextBorderStyleNone;
    
    [self addSubview:_textField];
    
    
    
}

@end
